@use 'sass:map';
@use '@angular/material' as mat;

@mixin color($config-or-theme) {
  $config: mat.get-color-config($config-or-theme);
  $foreground: map.get($config, foreground);
  $primary: map.get($config, primary);

  /**
   * @deprecated 迁移至全局样式
   */
  body.mobile {
    .cdk-overlay-container {
      z-index: 3000;
    }
  }

  .pac-indicator-market__detail-container {
    --ngm-indicator-app-bottom-sheet-height: calc(100vh - 50px);
    .mat-bottom-sheet-container {
      display: flex;
      background: unset;
      padding: 0;
      height: var(--ngm-indicator-app-bottom-sheet-height);
      max-height: var(--ngm-indicator-app-bottom-sheet-height);

      .mat-card {
        box-shadow: unset;
      }
    }
  }

  .pac-indicator-market__infinite-container.cdk-virtual-scroll-orientation-vertical
    .cdk-virtual-scroll-content-wrapper {
    max-width: 100%;
  }

  .pac-indicator-detail {
    .mat-mdc-card {
      .mat-mdc-card-header-text {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;

        .mat-mdc-card-title {
          @apply text-lg font-bold overflow-hidden text-ellipsis max-w-full;
        }

        .mat-mdc-card-subtitle {
          @apply text-base overflow-hidden text-ellipsis max-w-full mb-2;
        }
      }
    }

    .ngm-analytical-card {
      .ngm-card-header {
        white-space: nowrap;
      }
    }
  }
}

$density-cosy: 12px;

@mixin density($config-or-theme) {
  .indicator-market-app {
    .pac-indicator-market__drawer {
      padding: $density-cosy 0;

      .pac-indicator-market_-toolbar {
        padding: 0 $density-cosy;
      }
      .am-search {
        padding: 0 $density-cosy;
      }
    }

    pac-indicator-detail {
      .mat-mdc-card {
        .mat-mdc-card-header-text {
          .mat-mdc-card-title {
            margin: 0;
          }
          .mat-mdc-card-subtitle {
            margin: 0;
          }
        }
      }
    }

    .pac-indicator-market__infinite-container {
      .mat-mdc-list-item {
        --mdc-list-list-item-one-line-container-height: 70px;
        padding: $density-cosy 0;
        border-radius: $density-cosy;

        .pac-indicator__tag {
          font-size: 12px;
          height: 22px;
          line-height: 22px;
        }
      }
    }
  }

  pac-indicator-detail {
    .mat-mdc-card {
      .mat-mdc-card-header-text {
        margin: 0;
      }
    }
  }
}

@mixin theme($theme) {
  $color: mat.get-color-config($theme);
  $density: mat.get-density-config($theme);
  $typography: mat.get-typography-config($theme);

  @if $color != null {
    @include color($color);
  }
  @if $density != null {
    @include density($density);
  }
  @if $typography != null {
    @include typography($typography);
  }
}
